package com.example.demo.controller;


/**
 * 作者：石红宝
 * 时间：2019-5-27
 */

import com.example.demo.model.Pay;
import com.example.demo.service.PayService;
import com.example.demo.service.UserService;
import com.example.demo.tool.ResponseMessage;
import com.example.demo.tool.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController (value = "/Pay")
public class PayController {
    @Autowired
    private PayService payService;

    @CrossOrigin
    @RequestMapping(value = "/PaySelect")
    public Pay PaySelect(Integer pid) {
        return payService.PaySelect(pid);
    }

    @CrossOrigin//解决跨越问题
    @RequestMapping(value = "getPay")

    public ResponseMessage getPay() {
        List<Pay> listPay = payService.getPay();
        System.out.println("调用角色全部信息的方法");
        Map<String, List> map = new HashMap<>();
        map.put("list", payService.getPay());
        return Result.success("200", map);
    }


    @CrossOrigin//解决跨越问题
    @RequestMapping(value = "getbang")
    public List<Pay> getbang() {
        System.out.println("调用角色全部类型的接口");
        List<Pay> listRole = payService.getbang();
        return listRole;
    }

    @ApiOperation(value = "增加")
    @CrossOrigin
    @RequestMapping(value = "/PayAdd",method = RequestMethod.PUT)
    public int PayAdd(@RequestBody Pay paymodel) {
        return payService.PayAdd(paymodel);
    }

    @CrossOrigin
    @RequestMapping(value = "/PayUpdate", method = RequestMethod.PUT)
    public int PayUpdate(@RequestBody Pay paynodel) {
        //判断传入数据是否为空
        if (paynodel != null) {

        } else {

        }
        return payService.PayUpdate(paynodel);
    }

    @CrossOrigin
    @RequestMapping(value = "/PayDel", method = RequestMethod.PUT)
    public int updateRole(Integer pid ) {
        if (pid != null) {

        } else {

            System.out.println("请输入数据");
        }
        return payService.PayDel(pid);
    }

}
